package com.bob.demo.system.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.bob.demo.system.model.Menu;

public interface MenuRepository extends JpaRepository<Menu, String> {
	
	   @Query(value = "SELECT * FROM menu WHERE id in (select r.menu_id from role_menu r where  r.role_id in (SELECT u.role_id FROM user_role u WHERE u.user_id = ?1))", nativeQuery = true)  
	   @Modifying  
	   public List<Menu> findMenuByUserId(String userId);  
}
